﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace eLearning.Business
{
    public class LibraryItemAttachmentTranscriptRepository
    {
        // Create an instance of entities framework
        eLearningEntities entities = new eLearningEntities();
        public List<LibraryItemAttachmentTranscript> GetAll(int attachmentId)
        {
            return (from c in entities.LibraryItemAttachmentTranscripts where c.AttachmentId == attachmentId select c).ToList();
        }
        public List<LibraryItemAttachmentTranscript> GetAll()
        {
            return (from c in entities.LibraryItemAttachmentTranscripts select c).ToList();
        }
        public LibraryItemAttachmentTranscript GetSingle(int id)
        {
            return (from c in entities.LibraryItemAttachmentTranscripts where c.Id == id select c).FirstOrDefault();
        }
        public void Create(LibraryItemAttachmentTranscript _object)
        {
            entities.AddToLibraryItemAttachmentTranscripts(_object);
            entities.SaveChanges();
        }
        public void Update(LibraryItemAttachmentTranscript _object)
        {
            entities.SaveChanges();
        }
        public void Delete(int id)
        {
            var _object = (from _list in entities.LibraryItemAttachmentTranscripts where _list.Id == id select _list).First();
            entities.DeleteObject(_object);
            entities.SaveChanges();
        }
    }
}